#define _CRT_SECURE_NO_WARNINGS 1
#include "SList.h"

void SListTest1()
{
	SListNode* plist = NULL;
	SListPushBack(&plist, 1);
	SListPushBack(&plist, 2);
	SListPushBack(&plist, 3);
	SListPushBack(&plist, 4);

	SListPrint(plist);
}

void SListTest2()
{
	SListNode* plist = NULL;
	SListPushFront(&plist, 1);
	SListPushFront(&plist, 2);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 4);
	
	SListPrint(plist);

	SListPopBack(&plist);
	SListPrint(plist);

	SListPopBack(&plist);
	SListPrint(plist);

	SListPopBack(&plist);
	SListPrint(plist);

	SListPopBack(&plist);
	SListPrint(plist);
}

void SListTest3()
{
	SListNode* plist = NULL;
	SListPushFront(&plist, 1);
	SListPushFront(&plist, 2);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 4);
	SListPrint(plist);

	SListPopFront(&plist);
	SListPrint(plist);

	SListPopFront(&plist);
	SListPrint(plist);

	SListPopFront(&plist);
	SListPrint(plist);

	SListPopFront(&plist);
	SListPrint(plist);

}

void SListTest4()
{
	SListNode* plist = NULL;
	SListPushBack(&plist, 1);
	SListPushBack(&plist, 2);
	SListPushBack(&plist, 3);
	SListPushBack(&plist, 4);
	SListPrint(plist);

	SListNode* ret = SListFind(plist,2);
	SListInsert(&plist,ret, 10);
	SListPrint(plist);

}

void SListTest5()
{
	SListNode* plist = NULL;
	SListPushBack(&plist, 1);
	SListPushBack(&plist, 2);
	SListPushBack(&plist, 3);
	SListPushBack(&plist, 4);
	SListPrint(plist);

	SListNode* ret1 = SListFind(plist,2);
	SListErase(&plist, ret1);
	ret1 = NULL;

	SListPrint(plist);

	SListNode* ret2 = SListFind(plist, 4);
	SListInsertAfter(ret2, 2);

	SListPrint(plist);

	SListNode* ret3 = SListFind(plist, 3);
	SListEraseAfter(ret3);
	SListPrint(plist);
}

int main()
{
	SListTest5();
	return 0;
}